package pl.lodz.p.browarex.base;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import pl.lodz.p.browarex.base.interfaces.ICrudDao;
import pl.lodz.p.browarex.base.interfaces.ICrudService;
import pl.lodz.p.browarex.base.interfaces.IModel;



@Transactional
public abstract class BaseCrudService<DAO extends ICrudDao<MODEL, ID>, MODEL extends IModel, ID extends Serializable> extends BaseService implements ICrudService<DAO, MODEL, ID> {

	protected final ICrudDao<MODEL, ID> dao;

	public BaseCrudService(ICrudDao<MODEL, ID> dao) {
		this.dao = dao;
	}

	public MODEL load(ID id) {
		return this.dao.load(id);
	}

	public void save(MODEL model) {
		this.dao.save(model);
	}

	public void delete(ID id){
		this.dao.delete(id);
	}
	
	public List<MODEL> list() {
		return this.dao.list();
	}

}